package com.sec.etech.employeesync.util;

import com.sec.etech.employeesync.confighandler.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.HashMap;
import java.util.Map;

@Component
public class ConfigTableHandlerFactory {

    private final Map<String, ConfigTableHandler<?>> handlers = new HashMap<>();

    @Autowired
    public ConfigTableHandlerFactory(
            CompanyConfigHandler companyConfigHandler,
            DegreeConfigHandler degreeConfigHandler,
            DegreeSchoolConfigHandler degreeSchoolConfigHandler,
            DepartmentConfigHandler departmentConfigHandler,
            EducationConfigHandler educationConfigHandler,
            EthnicityConfigHandler ethnicityConfigHandler,
            GroupConfigHandler groupConfigHandler,
            IndustrialGroupConfigHandler industrialGroupConfigHandler,
            LearningFormConfigHandler learningFormConfigHandler,
            MajorConfigHandler majorConfigHandler,
            NationalityConfigHandler nationalityConfigHandler,
            NativePlaceConfigHandler nativePlaceConfigHandler,
            PoliticsConfigHandler politicsConfigHandler,
            PrimaryLevelJobConfigHandler primaryLevelJobConfigHandler,
            ProfessionalTitleConfigHandler professionalTitleConfigHandler,
            SecondaryLevelJobConfigHandler secondaryLevelJobConfigHandler,
            SkillLevelConfigHandler skillLevelConfigHandler,
            SubGroupConfigHandler subGroupConfigHandler,
            TertiaryLevelJobConfigHandler tertiaryLevelJobConfigHandler
    ) {
        handlers.put("company", companyConfigHandler);
        handlers.put("degree", degreeConfigHandler);
        handlers.put("school", degreeSchoolConfigHandler);
        handlers.put("department", departmentConfigHandler);
        handlers.put("education", educationConfigHandler);
        handlers.put("ethnicity", ethnicityConfigHandler);
        handlers.put("employeeGroup", groupConfigHandler);
        handlers.put("industrialGroup", industrialGroupConfigHandler);
        handlers.put("learningForm", learningFormConfigHandler);
        handlers.put("major", majorConfigHandler);
        handlers.put("nationality", nationalityConfigHandler);
        handlers.put("native_place", nativePlaceConfigHandler);
        handlers.put("politics", politicsConfigHandler);
        handlers.put("primaryLevelJob", primaryLevelJobConfigHandler);
        handlers.put("professionalTitle", professionalTitleConfigHandler);
        handlers.put("secondaryLevelJob", secondaryLevelJobConfigHandler);
        handlers.put("skillLevel", skillLevelConfigHandler);
        handlers.put("employeeSubgroup", subGroupConfigHandler);
        handlers.put("tertiaryLevelJob", tertiaryLevelJobConfigHandler);
    }

    public ConfigTableHandler<?> getHandler(String tableName) {
        return handlers.get(tableName);
    }
}
